//
//  WUPageNameCell.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/5/6.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "WUPageNameCell.h"

@interface WUPageNameCell()
{

    UIImageView *NVImageV;
}
@property (nonatomic,retain)UILabel *priceL;
@property (nonatomic,retain)UILabel *addressL;
@property (nonatomic,retain)UILabel *yearL;
@property (nonatomic,retain)UILabel *jobL;
@property (nonatomic,retain)UILabel *ageL;
@property (nonatomic,retain)UILabel *nvL;
@property (nonatomic,retain)UILabel *positionNameL;
@property (nonatomic,retain)UIImageView *myImageView;
@property (nonatomic,retain)UIImageView *sexImageView;
@property (nonatomic,retain)UILabel *styleL;
@property (nonatomic,retain)UILabel *guL;
@property (nonatomic,retain)UILabel *msL;
@end

@implementation WUPageNameCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}
- (void)creatView{
    self.contentView.backgroundColor = LV;
    _nameL = [UILabel new];
    _nameL.text = @"张叶君";
    _nameL.textColor = GH;
    _nameL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT * AUTO_WIDTH];
    [self.contentView addSubview:_nameL];
    [_nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5 * AUTO_HEIGHT);
        make.height.mas_equalTo(70/2 * AUTO_HEIGHT);
        make.left.mas_equalTo(15 * AUTO_WIDTH);
        
    }];
    
        UIView *line = [UIView new];
        line.backgroundColor = ZI;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(15 * AUTO_HEIGHT);
            make.left.mas_equalTo(_nameL.mas_right).offset(10 * AUTO_WIDTH);
            make.width.mas_equalTo(1.5 * AUTO_WIDTH);
            make.height.mas_equalTo(17 * AUTO_HEIGHT);
    
        }];
    
        _positionNameL = [UILabel new];
        [self.contentView addSubview:_positionNameL];
        _positionNameL.text = @"室内设计师";
        _positionNameL.textColor = ZI;
        _positionNameL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT * AUTO_WIDTH];
    
        [_positionNameL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.height.mas_equalTo(_nameL);
            make.left.mas_equalTo(line.mas_right).offset(10 * AUTO_WIDTH);
    
    
        }];
    
    //价格图片
    UIImageView *priceIV = [UIImageView new];
    [self.contentView addSubview:priceIV];
    priceIV.image = [UIImage imageNamed:@"qiang"];
    [priceIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_nameL.mas_bottom).offset(10/2 * AUTO_HEIGHT);
        make.left.mas_equalTo(_nameL);
        make.size.mas_equalTo(CGSizeMake(15 * AUTO_WIDTH, 15 * AUTO_HEIGHT));
        
    }];
    //价格
    _priceL = [UILabel new];
    [self.contentView addSubview:_priceL];
    _priceL.text = @"1000";
    _priceL.textColor = ZI;
    _priceL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_priceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(priceIV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
        
    }];
    
    //
    //定位图片
    UIImageView *addressIV = [UIImageView new];
    [self.contentView addSubview:addressIV];
    addressIV.image = [UIImage imageNamed:@"DIZHI"];
    //addressIV.backgroundColor = [UIColor redColor];
    [addressIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_priceL.mas_right).offset( 15 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    //定位名
    _addressL = [UILabel new];
    [self.contentView addSubview:_addressL];
    _addressL.text = @"杭州";
    _addressL.textColor = ZI;
    _addressL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_addressL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(addressIV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
    }];
    //年图片
    UIImageView *adgImageV = [UIImageView new];
    [self.contentView addSubview:adgImageV];
    adgImageV.image = [UIImage imageNamed:@"jingyan"];
    [adgImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_addressL.mas_right).offset(15 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    
    _ageL = [UILabel new];
    _ageL.text = @"1-2年";
    [self.contentView addSubview:_ageL];
    _ageL.textColor = ZI;
    _ageL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_ageL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(adgImageV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
    }];
    
    
    //年图片
    NVImageV = [UIImageView new];
    [self.contentView addSubview:NVImageV];
//    NVImageV.image = [UIImage imageNamed:@"nv"];
    [NVImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_ageL.mas_right).offset(15 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    
    _nvL = [UILabel new];
//    _nvL.text = @"女";
    [self.contentView addSubview:_nvL];
    _nvL.textColor = ZI;
    _nvL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_nvL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(NVImageV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
    }];
    
    
    
    _myImageView = [UIImageView new];
    [self.contentView addSubview:_myImageView];
    
    _myImageView.image = [UIImage imageNamed:@"backImage"];
    [_myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15 * AUTO_HEIGHT);
        make.width.mas_equalTo(55 * AUTO_WIDTH);
        make.height.mas_equalTo(55 * AUTO_HEIGHT);
        // make.left.mas_equalTo(_positionNameL);
        make.right.mas_equalTo(self).mas_equalTo(- 20 * AUTO_WIDTH);
        
    }];
    _myImageView.layer.masksToBounds = YES;
    _myImageView.layer.cornerRadius = 55/2 * AUTO_WIDTH;
    _myImageView.contentMode = UIViewContentModeScaleAspectFill;
 
    _sexImageView = [UIImageView new];
    //_sexImageView.backgroundColor = [UIColor redColor];
    _sexImageView.image = [UIImage imageNamed:@"xingbeinan"];
    [self.contentView addSubview:_sexImageView];
    [_sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_myImageView).offset(5 * AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(15 *AUTO_WIDTH, 15 * AUTO_HEIGHT));
        make.right.mas_equalTo(_myImageView.mas_right).offset(-0 * AUTO_WIDTH);
        
    }];

    _jobL = [UILabel new];
    _jobL.text = @"离职-随时开始";
    _jobL.textColor = ZI;
    _jobL.font = [UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    [self.contentView addSubview:_jobL];
    [_jobL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_priceL.mas_bottom);
        make.left.mas_equalTo(_nameL);
        make.height.mas_equalTo(25 * AUTO_HEIGHT);
        
        
    }];

    UIImageView *li = [UIImageView new];
    [self.contentView addSubview:li];
    [li mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_jobL.mas_bottom).offset(1 * AUTO_HEIGHT);
        make.left.mas_equalTo(1 * AUTO_WIDTH);
        make.height.mas_equalTo(1.5 * AUTO_HEIGHT);
        make.right.mas_equalTo(- 1 * AUTO_WIDTH);
        
    }];
    li.image = [UIImage imageNamed:@"虚线"];
 
    //风格
    UIImageView *fengeV = [UIImageView new];
    [self.contentView addSubview:fengeV];
    fengeV.image = [UIImage imageNamed:@"fenge"];
    [fengeV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(li.mas_bottom).offset(8 * AUTO_HEIGHT);
        make.left.mas_equalTo(_nameL);
        make.size.mas_equalTo(priceIV);
        
    }];
    
    _styleL = [UILabel new];
    _styleL.text = @"现代简约";
    _styleL.textColor = ZI;
    _styleL.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [self.contentView addSubview:_styleL];
    [_styleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(fengeV);
        make.left.mas_equalTo(fengeV.mas_right).offset(5 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        //  make.right.mas_equalTo(self.mas_right).offset(-40 * AUTO_WIDTH);
        //        make.width.mas_equalTo()
    }];
    
    
    UILabel *henglabel=[[UILabel alloc]init];
    [self.contentView addSubview:henglabel];
    henglabel.backgroundColor=ZI;
    [henglabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(li.mas_bottom).offset(10 *AUTO_HEIGHT);
        make.left.equalTo(_styleL.mas_right).offset(5 *AUTO_WIDTH);
        make.height.mas_equalTo(12 *AUTO_HEIGHT);
        make.width.mas_equalTo(1 *AUTO_WIDTH);
    }];
    
    
    _guL=[UILabel new];
    _guL.text=@"古典式";
    _guL.textColor=ZI;
    _guL.font=[UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [self.contentView addSubview:_guL];
    [_guL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(fengeV);
        make.left.mas_equalTo(henglabel.mas_right).offset(5 *AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
    }];
    
    UILabel *henglabel1=[[UILabel alloc]init];
    [self.contentView addSubview:henglabel1];
    henglabel1.backgroundColor=ZI;
    [henglabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(li.mas_bottom).offset(10 *AUTO_HEIGHT);
        make.left.equalTo(_guL.mas_right).offset(5 *AUTO_WIDTH);
        make.height.mas_equalTo(12 *AUTO_HEIGHT);
        make.width.mas_equalTo(1 *AUTO_WIDTH);
    }];
    
    _msL=[UILabel new];
    _msL.text=@"美式乡村";
    _msL.textColor=ZI;
    _msL.font=[UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [self.contentView addSubview:_msL];
    [_msL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(fengeV);
        make.left.mas_equalTo(henglabel1.mas_right).offset(5 *AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
    }];
}

-(void)settingRegisnModel:(ResignModel *)moedl{
    _nameL.text =  moedl.name;
    _positionNameL.text = moedl.jobtype;
    _addressL.text = moedl.city;
    _priceL.text = moedl.price;
    _ageL.text = moedl.exper;
   
    if ([moedl.sex isEqualToString:@"女"]) {
       
        _sexImageView.image = [UIImage imageNamed:@"xingbeinv"];

    }
    else if ([moedl.sex isEqualToString:@"男"]){
        _sexImageView.image = [UIImage imageNamed:@"xingbeinan"];


    }
    
    NSArray *styleArray = [moedl.jobtype componentsSeparatedByString:@","];
    
    switch (styleArray.count) {
        case 0:
            _styleL.text = moedl.jobtype;
            break;
        case 2:
            _styleL.text = styleArray[0];
            _guL.text = styleArray[1];
            break;
        case 3:
            _styleL.text = styleArray[0];
            _guL.text = styleArray[1];
            _msL.text = styleArray[2];
            break;
        default:
            break;
    }
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,moedl.headpic]] placeholderImage:nil];
    
    

    
}
@end
